/*
* 私募大赛
*Home.js*/

import React, {Component,PropTypes} from 'react';
import {connect} from 'dva';
import {routerRedux,withRouter } from 'dva/router';
import { Row,Col,Button} from 'antd';
import Tabtitle from '../../../components/common/TabTitle';
import {GameNameSelect,DateRangePicker} from '../components/SelectToolBar';
import CompetitionList from './component/CompetitionList';
import GameDetailsPage from './component/GameDetailsPage';

import style from './home.less';

/*
*gameName [查询比赛名称]
*beginDate [查询比赛开始时间]
*endDate [查询比赛结束时间]
*DetailsData[比赛详情]
*/
const PrivateGame = ({dispatch,privateGame,location:{pathname,query}}) => {
	const {
		gameName,
		qbeginDate,
		qendDate,
		DetailsData,
		isShow,
		fundGameList
	} =privateGame;
	const tag = 'privateGame';
	console.log('PrivateGame>',privateGame)
	function queryData(){
		if(gameName!==''&&qbeginDate==''&&qendDate==''){
			dispatch({
				type:'privateGame/fundCompetition',
				payload:{
					'name':gameName,
				}
			})
		}else if(gameName==''&&qbeginDate==''&&qendDate==''){
			dispatch({
				type:'privateGame/fundCompetition',
				payload:{
					'name':gameName,
				}
			})
		}else if(gameName==''&&qbeginDate!==''&&qendDate!==''){
			dispatch({
				type:'privateGame/fundCompetition',
				payload:{
					'beginDate':qbeginDate,
					'endDate':qendDate
				}
			})
		}else if(gameName!==''&&qbeginDate!==''&&qendDate!==''){
			dispatch({
				type:'privateGame/fundCompetition',
				payload:{
					'name':gameName,
					'beginDate':qbeginDate,
					'endDate':qendDate
				}
			})
		}
	}
	
	return (
		<div>
			<Tabtitle value={'比赛列表'}/>
			<div className="page-privateGame-home content-inner">
				<div className={style.privateGame}>
					{/*<Row type="flex" justify="start" align="middle" style={{marginTop:10,marginBottom:16,marginLeft:20}}>*/}
					   <Row type="flex" justify="start" align="middle" style={{marginBottom:20}}>
						{/*<Col span={5}>*/}
							<span>比赛名称: </span>&nbsp;&nbsp;
							<GameNameSelect
								dispatch={dispatch}
								tag={tag}
							/>
						{/*</Col>*/}
						{/*<Col span={6}>*/}
							<span>比赛时间: </span>&nbsp;&nbsp;
							<DateRangePicker
								dispatch={dispatch}
								tag={tag}
							/>
						{/*</Col>*/}
						{/*<Col span={3}>*/}
							<Button type="primary" onClick={queryData}>查询</Button>
						{/*</Col>*/}
					</Row>
					<Row type="flex" gutter={8}>
						{/*<Col span={7} style={{marginLeft:20,marginBottom:30}} className={style.ssss}>*/}
						<Col span={8} style={{paddingRight:10}} className={style.ssss}>
							
							{
								fundGameList?<CompetitionList/>:<span>暂无数据</span>
							}
						</Col>
						<Col span={16}>
						{
							DetailsData&&isShow?<GameDetailsPage/>:null
						}
						</Col>
					</Row>
				</div>
			</div>
		</div>
	)
}

PrivateGame.propTypes = {}

export default connect(({privateGame})=>({privateGame}))(PrivateGame)